package com.apinji.alipay.common;

import com.apinji.common.plugin.StrUtils;

public enum AlipayTradeStatusEnum {

    WAIT_BUYER_PAY("WAIT_BUYER_PAY", "交易创建，等待买家付款"),

    TRADE_CLOSED("TRADE_CLOSED", "未付款交易超时关闭，或支付完成后全额退款"),

    TRADE_SUCCESS("TRADE_SUCCESS", "交易支付成功"),

    TRADE_FINISHED("TRADE_FINISHED", "交易结束，不可退款")


    ;


    private String status;
    private String msg;

    AlipayTradeStatusEnum(String status, String msg){
        this.status = status;
        this.msg = msg;
    }


    public static String getMsg(String status){
        if(StrUtils.isEmpty(status)) {
            return "";
        }
        for(int i = 0; i < AlipayTradeStatusEnum.values().length; i++) {
            if (AlipayTradeStatusEnum.values()[i].getStatus().equals(status)) {
                return AlipayTradeStatusEnum.values()[i].getMsg();
            }
        }
        return "status code not found : " + status;
    }


    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
